#ifndef __KERNEL_HEAP_H__
#define __KERNEL_HEAP_H__

#ifdef __cplusplus
extern "C" {
#endif

// definition of errors
// todo: need to ingegrate to galobal error table
#define HEAP_PF_MODE_ERROR				(1)
#define HEAP_PF_PAGE_PROTECTION_FAULT	(2)
#define HEAP_PF_ACCESS_ERROR			(3)
#define HEAP_PF_OUT_OF_MEM				(4)
#define HEAP_PF_VMA_NOT_A_HEAP			(5)
#define HEAP_PF_SHORTAGE_OF_PAGE		(6)
#define HEAP_PF_FAIL_TO_MAP_PAGE		(7)

struct vma;

// virtual malloc for pages
// from kernel default heap
void* vmalloc(size_t pages);

// free pages allocated by vmalloc
// to kernel default heap
int vfree(void* addr, size_t pages);

// virtual malloc for pages
// from specific heap
void* heap_vmalloc(struct vma* vma, size_t pages);

// free pages allocated by heap_vmalloc
// to specific heap
// make sure the heap specified is the
// same one used to call heap_vmalloc
int heap_vfree(struct vma* vma, void* addr, size_t pages);

// global initialization
int global_init_heap(void);
int global_vma_init_kenrel_heap(void);

#ifdef __cplusplus
}
#endif
#endif
/* EOF */
